Ext.define('Sh.ux.PeCombobox', {
    extend: 'Ext.form.field.ComboBox',
    alias : 'widget.pecombobox',
	fieldLabel: '企业',
	labelWidth: 35,
	width: 150,
	displayField: 'name',
    valueField: 'id',
    queryMode: 'local',
    hidden: true,
    load: undefined,//数据加载并选中一条数据后的回调函数function(store,recs,scope)
	initComponent : function() {
		var me = this;
		var ls = {};
		me.store = Ext.create('Ext.data.Store',{
			autoLoad: true,
			fields: ['id','name'],
			proxy: {
				type: 'ajax',
				url: 'enterprise/getPrivEnterPrise.do'
			},
			listeners: {
				load: function(st,recs,sc){
					if(recs.length == 0){
						var ownerCt = me.ownerCt;
						if(ownerCt)ownerCt.setDisabled(true);
						Ext.Msg.alert('提示','您没有数据企业权限,请联系管理员！');
					}
					else if(recs.length == 1){
						me.select(recs[0]);
					}
					else{
						me.setVisible(true);
						var rec = undefined;
						if(user.etype == 0){
							rec = st.findRecord('id',user.eid);
						}
						else{
							rec = recs[0];
						}
						me.select(rec);
					}
					
					if(me.load){
						me.load(st,recs,sc);
					};
				}
			}
		});
		
		me.callParent();
	}
});